<HTML><HEAD>
<TITLE>netwib doc_html (version 5.39.0)</TITLE>
</HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H2><A HREF="../../index.html">main index</A></H2>
<H2><A HREF="../dat.html">section index</A></H2><HR><BR>
<PRE>

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000"><B>/***************************************************************
 * A <FONT COLOR="#000088">netwib_ring_index</FONT> is used to loop through a ring.         *
 *                                                             *
 * When the ring is only read, several indexes                 *
 * can simultaneously loop through the ring.                   *
 *                                                             *
 * However, when the ring is edited, strange behavior can      *
 * occur when a <FONT COLOR="#000088">netwib_ring_index_xyz</FONT> function is called,      *
 * depending on function used to edit the ring:                *
 *  - netwib_ring_index_next,                                  *
 *    netwib_ring_index_previous,                              *
 *    netwib_ring_index_this_value,                            *
 *    netwib_ring_index_this_replace,                          *
 *    netwib_ring_index_this_del:                              *
 *      No problem.                                            *
 *  - netwib_ring_index_add_before,                            *
 *    netwib_ring_index_add_after,                             *
 *    netwib_ring_add_first,                                   *
 *    netwib_ring_add_last,                                    *
 *    netwib_ring_index_add_ring_xyz:                          *
 *      The added item(s) may be returned or not returned,     *
 *      depending on the insertion position relative to the    *
 *      index position.                                        *
 *  - netwib_ring_sort,                                        *
 *    netwib_ring_group:                                       *
 *      The reordered items may be returned twice or never     *
 *      returned. There is no way to know.                     *
 *  - netwib_ring_del_criteria,                                *
 *    netwib_ring_del_duplicate:                               *
 *      You should not use them because if the item pointed by *
 *      the index is deleted, it will cause an access to freed *
 *      memory. You may use them only if you are sure to not   *
 *      delete the current item.                               *
 *      However, after netwib_ring_index_this_del, you must    *
 *      not use them because there is not way to know if they  *
 *      will delete internal items.                            *
 ***************************************************************/</B></FONT>

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
typedef struct <FONT COLOR="#000088">netwib_ring_index</FONT> <FONT COLOR="#000088">netwib_ring_index</FONT>;

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Name : netwib_ring_index_init
   Description :
     Initialize a <FONT COLOR="#000088">netwib_ring_index</FONT> used to loop through
     a netwib_ring.
   Input parameter(s) :
   Input/output parameter(s) :
   Output parameter(s) :
     **ppringindex : <FONT COLOR="#000088">netwib_ring_index</FONT> allocated and initialized
   Normal return values :
     <FONT COLOR="#000044">NETWIB_ERR_OK</FONT> : ok
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_ring_index_init</B>(<FONT COLOR="#000088">netwib_constring</FONT> *pring,
                                  <FONT COLOR="#000088">netwib_ring_index</FONT> **ppringindex);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Name : netwib_ring_index_close
   Description :
     Close a netwib_ringindex.
   Input parameter(s) :
   Input/output parameter(s) :
     **ppringindex : <FONT COLOR="#000088">netwib_ring_index</FONT> closed
   Output parameter(s) :
   Normal return values :
     <FONT COLOR="#000044">NETWIB_ERR_OK</FONT> : ok
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_ring_index_close</B>(<FONT COLOR="#000088">netwib_ring_index</FONT> **ppringindex);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Types to control a <FONT COLOR="#000088">netwib_ring_index</FONT> */</FONT>
typedef enum {
  <FONT COLOR="#000044">NETWIB_RING_INDEX_CTLTYPE_REWIND</FONT> = 1,  <FONT COLOR="#880000">/* position at beginning */</FONT>
  <FONT COLOR="#000044">NETWIB_RING_INDEX_CTLTYPE_INDEX</FONT>        <FONT COLOR="#880000">/* reset with index pos */</FONT>
} <FONT COLOR="#000088">netwib_ring_index_ctltype</FONT>;
<FONT COLOR="#880000">/* Those functions permit to set/get parameters (pointer and
   integer) about a netwib_ring_index. It should not be used directly,
   but by the defines.
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_ring_index_ctl_set</B>(<FONT COLOR="#000088">netwib_ring_index</FONT> *pringindex,
                                     <FONT COLOR="#000088">netwib_ring_index_ctltype</FONT> type,
                                     <FONT COLOR="#000088">netwib_ptr</FONT> p,
                                     <FONT COLOR="#000088">netwib_uint32</FONT> ui);
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_ring_index_ctl_get</B>(<FONT COLOR="#000088">netwib_ring_index</FONT> *pringindex,
                                     <FONT COLOR="#000088">netwib_ring_index_ctltype</FONT> type,
                                     <FONT COLOR="#000088">netwib_ptr</FONT> p,
                                     <FONT COLOR="#000088">netwib_uint32</FONT> *pui);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* <FONT COLOR="#000088">netwib_err</FONT> f(<FONT COLOR="#000088">netwib_ring_index</FONT> *pringindex); */</FONT>
<FONT COLOR="#008800">#define <B>netwib_ring_index_ctl_set_rewind</B>(pringindex) <B>netwib_ring_index_ctl_set</B>(pringindex,<FONT COLOR="#000044">NETWIB_RING_INDEX_CTLTYPE_REWIND</FONT>,NULL,0)</FONT>
<FONT COLOR="#880000">/* <FONT COLOR="#000088">netwib_err</FONT> f(<FONT COLOR="#000088">netwib_ring_index</FONT> *pringindex,<FONT COLOR="#000088">netwib_ring_index</FONT> *pringindexref);*/</FONT>
<FONT COLOR="#008800">#define <B>netwib_ring_index_ctl_set_index</B>(pringindex,pringindexref) <B>netwib_ring_index_ctl_set</B>(pringindex,<FONT COLOR="#000044">NETWIB_RING_INDEX_CTLTYPE_INDEX</FONT>,pringindexref,0)</FONT>

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Name : netwib_ring_index_next_criteria
   Description :
     Get the next item in the ring.
   Input parameter(s) :
     pfunc_criteria : function used to decide to remove an item
                      If this function is NULL, no criterion is
                      applied.
   Input/output parameter(s) :
     *pringindex : netwib_ring_index
     pinfos : optional parameter (can be NULL) which will be
              used as the parameter for pfunc_criteria.
              This may be used to send information to *pfunc_criteria.
   Output parameter(s) :
     *ppitem : pointer to the memory containing the item
   Normal return values :
     <FONT COLOR="#000044">NETWIB_ERR_OK</FONT> : ok
     <FONT COLOR="#000044">NETWIB_ERR_DATAEND</FONT> : end of the ring reached
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_ring_index_next_criteria</B>(<FONT COLOR="#000088">netwib_ring_index</FONT> *pringindex,
                                           <FONT COLOR="#000088">netwib_ring_criteria_pf</FONT> pfunc_criteria,
                                           <FONT COLOR="#000088">netwib_ptr</FONT> pinfos,
                                           <FONT COLOR="#000088">netwib_ptr</FONT> *ppitem);
<FONT COLOR="#008800">#define <B>netwib_ring_index_next</B>(pringindex,ppitem) <B>netwib_ring_index_next_criteria</B>(pringindex,NULL, NULL,ppitem)</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_ring_index_previous_criteria</B>(<FONT COLOR="#000088">netwib_ring_index</FONT> *pringindex,
                                               <FONT COLOR="#000088">netwib_ring_criteria_pf</FONT> pfunc_criteria,
                                               <FONT COLOR="#000088">netwib_ptr</FONT> pinfos,
                                               <FONT COLOR="#000088">netwib_ptr</FONT> *ppitem);
<FONT COLOR="#008800">#define <B>netwib_ring_index_previous</B>(pringindex,ppitem) <B>netwib_ring_index_previous_criteria</B>(pringindex,NULL, NULL,ppitem)</FONT>

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Name : netwib_ring_index_add_before
   Description :
     Add an item in the ring.
   Input parameter(s) :
   Input/output parameter(s) :
     *pringindex : netwib_ring_index
   Output parameter(s) :
     *ppitem : pointer to the memory containing the item
   Normal return values :
     <FONT COLOR="#000044">NETWIB_ERR_OK</FONT> : ok
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_ring_index_add_before</B>(<FONT COLOR="#000088">netwib_ring_index</FONT> *pringindex,
                                        <FONT COLOR="#000088">netwib_constptr</FONT> pitem);
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_ring_index_add_after</B>(<FONT COLOR="#000088">netwib_ring_index</FONT> *pringindex,
                                       <FONT COLOR="#000088">netwib_constptr</FONT> pitem);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Name : netwib_ring_index_this_value
   Description :
     Re-give the last value.
   Input parameter(s) :
   Input/output parameter(s) :
     *pringindex : netwib_ring_index
   Output parameter(s) :
     *ppitem : pointer to the memory containing the item
   Normal return values :
     <FONT COLOR="#000044">NETWIB_ERR_OK</FONT> : ok
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_ring_index_this_value</B>(<FONT COLOR="#000088">netwib_ring_index</FONT> *pringindex,
                                        <FONT COLOR="#000088">netwib_ptr</FONT> *ppitem);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Name : netwib_ring_index_this_del
   Description :
     Delete the last given value by a netwib_ring_index_next
     function.
   Input parameter(s) :
     eraseitem : if true, function pfunc_erase (set in
                 netwib_hash_init) is called to erase the
                 item located at position
   Input/output parameter(s) :
     *pringindex : netwib_ring_index
   Output parameter(s) :
   Normal return values :
     <FONT COLOR="#000044">NETWIB_ERR_OK</FONT> : ok
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_ring_index_this_del</B>(<FONT COLOR="#000088">netwib_ring_index</FONT> *pringindex,
                                      <FONT COLOR="#000088">netwib_bool</FONT> eraseitem);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Name : netwib_ring_index_this_replace
   Description :
     Replace value, but keep the same key.
   Input parameter(s) :
     pitem : pointer to an allocated memory containing the item
     erasepreviousitem : if true, function pfunc_erase (set in
                         netwib_ring_init) is called to erase the
                         item previously located in the ring
   Input/output parameter(s) :
     *pringindex : netwib_ring_index
   Output parameter(s) :
   Normal return values :
     <FONT COLOR="#000044">NETWIB_ERR_OK</FONT> : ok
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_ring_index_this_replace</B>(<FONT COLOR="#000088">netwib_ring_index</FONT> *pringindex,
                                          <FONT COLOR="#000088">netwib_constptr</FONT> pitem,
                                          <FONT COLOR="#000088">netwib_bool</FONT> erasepreviousitem);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Name : netwib_ring_index_add_ring_criteria
   Description :
     Add a ring within another ring. Only items matching a
     criterion are added.
   Input parameter(s) :
     *pringindex : ring is added after this index
     *pringtoadd : <FONT COLOR="#000088">netwib_ring</FONT> to add in pring
     pfunc_criteria : function used to decide to add an item
                      If this function is NULL, no criterion is
                      applied.
     duplicateitems : if true, function pfunc_duplicate (set in
                      netwib_ring_init) is called to duplicate
                      items
   Input/output parameter(s) :
     *pring : <FONT COLOR="#000088">netwib_ring</FONT> where to work
     pinfos : optional parameter (can be NULL) which will be
              used as the parameter for pfunc_criteria.
              This may be used to send information to *pfunc_criteria.
   Output parameter(s) :
   Normal return values :
     <FONT COLOR="#000044">NETWIB_ERR_OK</FONT> : ok
   Note :
     If an error occurs during addition, ring will only
     contain partial data.
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_ring_index_add_ring_criteria</B>(<FONT COLOR="#000088">netwib_ring_index</FONT> *pringindex,
                                               <FONT COLOR="#000088">netwib_ring</FONT> *pringtoadd,
                                               <FONT COLOR="#000088">netwib_ring_criteria_pf</FONT> pfunc_criteria,
                                               <FONT COLOR="#000088">netwib_ptr</FONT> pinfos,
                                               <FONT COLOR="#000088">netwib_bool</FONT> duplicateitems);
<FONT COLOR="#008800">#define <B>netwib_ring_index_add_ring_all</B>(pringindex,pringtoadd,duplicateitems) <B>netwib_ring_index_add_ring_criteria</B>(pringindex,pringtoadd,NULL,NULL,duplicateitems)</FONT>
</PRE><BR><BR><HR><BR>
<H2><A HREF="../../index.html">main index</A></H2>
<H2><A HREF="../dat.html">section index</A></H2>
</BODY></HTML>
